/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.mail.service.order;

import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import info.peigen.hotpot.common.service.base.exception.BusinessException;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

import java.util.Map;

/**
 * <b>(MimeMailOrder)</b>
 * Mime邮件
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/11/16
 */
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class MimeMailOrder extends AbstractMailServiceOrder {
    String              context;
    /** 模版Id */
    String              templateId;
    /** 模版内容 */
    Map<String, Object> templateMap;
    /** 附件，key=文件名，value=文件地址 */
    Map<String, String> attachments;

    @Override
    public void check() {
        super.check();

        if (StrUtil.isNotEmpty(templateId)) {
            Assert.notEmpty(templateMap, () -> new BusinessException("templateId 和 templateMap 不得同时为空！"));
        }
    }
}